{include file="header.html"}
{include file="title.html"}
<script type="text/javascript">
    $(function() {
        $('#find_password_form').validate({
            errorPlacement: function(error, element) {
                var error_td = element.parent('td');
                error_td.find('.field_notice').hide();
                error_td.append(error);
            },
            success: function(label) {
                label.addClass('validate_right').text('OK!');
            },
            rules: {
                username: {
                    required: true
                },
                phone_mob: {
                    required: true,
                    number: true,
                    byteRange: [11, 11, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=check_mobile&type=find',
                        type: 'get',
                        data: {
                            phone_mob: function() {
                                return $('#phone_mob').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_mobile');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {

                            $('#checking_mobile').hide();
                        }
                    }
                },
                confirm_code: {
                    required: true,
                    number: true,
                    byteRange: [6, 6, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=cmc&ajax=1',
                        type: 'get',
                        data: {
                            confirm_code: function() {
                                return $('#confirm_code').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_code');
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {
                            $('#checking_code').hide();
                        }
                    }
                }
            },
            messages: {
                username: {
                    required: '{$lang.username_required}'
                },
                phone_mob: {
                    required: '{$lang.phone_mob_required}',
                    number: '{$lang.phone_mob_number}',
                    byteRange: '{$lang.phone_mob_limit}',
                    remote: '{$lang.mobile_not_exsit}'
                },
                confirm_code: {
                    required: '{$lang.mobile_code_required}',
                    number: '{$lang.mobile_code_must_be_number}',
                    byteRange: '{$lang.mobile_code_limit}',
                    remote: '{$lang.mobile_code_error}'
                }

            }
        });

        var canSend = true;
        var time = 60;
        var dtime = 60;
        $("#sendsms").bind('click', function() {
            var btn = $(this);
            if (!canSend)
                return;

            var sendaddress = $('#phone_mob').val();
            var fhm = $("label[for='phone_mob']").text();
            if (fhm != '' && fhm != "OK!") {
                alert(lang.pls_enter_right_phone);
                return;
            }
              btn.attr("disabled","true");
            $.getJSON('index.php?app=member&act=send_code&type=find', {mobile: sendaddress}, function(result)
            {
                if (result.done == true) {
                    var hander = setInterval(function() {
                        if (time <= 0) {
                            canSend = true;
                            clearInterval(hander);
                            btn.val(lang.resend_msg);
                            btn.removeAttr("disabled");
                            time = dtime;
                        } else {
                            canSend = false;
                            btn.attr({
                                "disabled": "disabled"
                            });
                            btn.val(time + lang.after_minut_send);
                            time--;
                        }
                    },
                            1000);
                    alert(lang.msg_has_send + sendaddress +  lang.pls_check_receive);
                     btn.removeAttr("disabled");
                } else {
                    alert(result.msg);
                     btn.removeAttr("disabled");
                }
            });
        });
    });
</script>   


<!-----登录--------->
<div class="login_panel" >
    <form class="login_box" id="find_password_form" method="post">
        <table  width="100%">
            <tr>
                <td> <input placeholder="{$lang.your_username}" type="text" name="username" id="username" class="text">
                    <label class="field_notice"></label></td>
            </tr>
            <tr>
                <td> <input placeholder="{$lang.phone_mob}" type="text" name="phone_mob" id="phone_mob" class="text">
                    <label class="field_notice"></label></td>
            </tr>
            <tr> 
                <td>  
                    <input type="button" id="sendsms" value="{$lang.send_code}"/>
                </td>
            </tr>
            <tr> 
                <td>  
                    <input placeholder="{$lang.confirm_code}" id="confirm_code"  name="confirm_code" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            

            <tr>
                <td>
                    <input  value="{$lang.Find_my_mobile}"  type="submit" class="red_btn">
                </td>
            </tr>
        </table>
        <input type="hidden" name="ret_url" value="{$ret_url}" />
        <p><a href="{url app=member&act=login&ret_url=$ret_url}" >{$lang.shell}</a><a href="index.php?app=find_password" class="fr">{$lang.find_by_mail}</a></p>
    </form>
</div>


{include file="footer.html"}